package guiElements;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Point;
import java.util.ArrayList;

import javax.swing.JLabel;
import javax.swing.JPanel;

public class PatternSelectorPanel extends JPanel {

	private PatternSelector dots, floral, geo, lattice, large, plaid, scrolls,
			small, solid, stripes, texture, tSolid;

	PatternSelectorPanel() {
		this.setLayout(null);
		setBackground(Color.white);
		JPanel title = new JPanel();
		title.setSize(new Dimension(550, 25));
		title.setLocation(new Point(0, 0));
		title.setLayout(null);
		title.setBackground(Color.white);
		JLabel titleLabel = new JLabel("Select Patterns:");
		titleLabel.setBackground(Color.white);
		titleLabel.setFont(new Font("Georgia", Font.BOLD, 14));
		titleLabel.setSize(new Dimension(150, 25));
		titleLabel.setLocation(0, 0);
		title.add(titleLabel);

		JPanel selector = new JPanel();
		selector.setSize(new Dimension(550, 160));
		selector.setLocation(new Point(25, 25));
		selector.setLayout(new GridLayout(4, 3));
		dots = new PatternSelector("Dots");
		selector.add(dots);
		floral = new PatternSelector("Floral");
		selector.add(floral);
		geo = new PatternSelector("Geometric");
		selector.add(geo);
		lattice = new PatternSelector("Lattice/Diamond");
		selector.add(lattice);
		large = new PatternSelector("Large Scale");
		selector.add(large);
		plaid = new PatternSelector("Plaid/Checks");
		selector.add(plaid);
		scrolls = new PatternSelector("Scrolls");
		selector.add(scrolls);
		small = new PatternSelector("Small Scale");
		selector.add(small);
		solid = new PatternSelector("Solid");
		selector.add(solid);
		stripes = new PatternSelector("Stripes");
		selector.add(stripes);
		texture = new PatternSelector("Texture");
		selector.add(texture);
		tSolid = new PatternSelector("Tonal Solid");
		selector.add(tSolid);

		add(title);
		add(selector);
	}

	public ArrayList<String> getSelectedPatterns() {
		ArrayList<String> selectedPatterns = new ArrayList<String>(0);
		if (dots.patternSelected() != null) {
			selectedPatterns.add(dots.patternSelected());
		}
		if (floral.patternSelected() != null) {
			selectedPatterns.add(floral.patternSelected());
		}
		if (geo.patternSelected() != null) {
			selectedPatterns.add(geo.patternSelected());
		}
		if (lattice.patternSelected() != null) {
			selectedPatterns.add(lattice.patternSelected());
		}
		if (large.patternSelected() != null) {
			selectedPatterns.add(large.patternSelected());
		}
		if (plaid.patternSelected() != null) {
			selectedPatterns.add(plaid.patternSelected());
		}
		if (scrolls.patternSelected() != null) {
			selectedPatterns.add(scrolls.patternSelected());
		}
		if (small.patternSelected() != null) {
			selectedPatterns.add(small.patternSelected());
		}
		if (solid.patternSelected() != null) {
			selectedPatterns.add(solid.patternSelected());
		}
		if (stripes.patternSelected() != null) {
			selectedPatterns.add(stripes.patternSelected());
		}
		if (texture.patternSelected() != null) {
			selectedPatterns.add(texture.patternSelected());
		}
		if (tSolid.patternSelected() != null) {
			selectedPatterns.add(tSolid.patternSelected());
		}
		return selectedPatterns;
	}

	public void reset() {
		dots.getPatternCheckBox().setSelected(false);
		floral.getPatternCheckBox().setSelected(false);
		geo.getPatternCheckBox().setSelected(false);
		lattice.getPatternCheckBox().setSelected(false);
		large.getPatternCheckBox().setSelected(false);
		plaid.getPatternCheckBox().setSelected(false);
		scrolls.getPatternCheckBox().setSelected(false);
		small.getPatternCheckBox().setSelected(false);
		solid.getPatternCheckBox().setSelected(false);
		stripes.getPatternCheckBox().setSelected(false);
		texture.getPatternCheckBox().setSelected(false);
		tSolid.getPatternCheckBox().setSelected(false);
	}

}
